<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
	content="initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<title>购票</title>
<link rel="stylesheet" href="${ctx}/static/plug/weui/css/weui.css"
	media="all">
<link rel="stylesheet" href="${ctx}/static/plug/weui/css/weuix.css"
	media="all">
<link rel="stylesheet" href="${ctx}/static/css/addCarNo.css" media="all">
<link rel="stylesheet" href="${ctx}/static/css/ticket/index.css"
	media="all">
<style type="text/css">
.weui-btn{
	padding: 5px 0;
	width: 150px;
	height: 35px;
	margin-right: 15px;
}
.weui-icon-radio{
	margin-right: 0px;
}
.weui-form-text{
	margin-right: 0px;
}
 .weui-switch-cp__box{
    right: -15px;
 }
 .scenicDesc{
 	width: 95%;
	background-color: white;
	border-radius: 5px;
	margin: 10px auto;
 }
 .scenicDesc >p{
 	padding: 4px 15px;
 	font-size: 14px;
 	display: none;
 }
 .desc{
 	color: #333;
 }
 #scenicDesc{
 	color: #333;
 	border-bottom: 1px solid #ebebeb; 
 	padding: 10px 15px;
 	font-size: 16px;
 	display: block;
 }
 #scenicDesc > img{
 	width: 25px;
 	height: 25px;
 	display: inline-block;
 	float: right;
 }
</style>

</head>
<body>
	<input type="hidden" value="${userInfo.id}" id="userId">
	<input  type="hidden" value="${userInfo.payOpenid  }" id="payOpenid">
	<div class="header"
		style="background-image: url('${scenicSpotDetailVo.img}');">
		<p>${scenicSpotDetailVo.name}</p>
		<p>游园时间：${scenicSpotDetailVo.openTime}</p>
	</div>

	<div class="subject">
		<div class="timeAndTicket">
			<div style="height: 1px; width: 100%"></div>


			<c:forEach var="ticketInfo" items="${ticketInfoList}">
				<div class="ticket2"  minTime="${ticketInfo.startTimeStr }" maxTime="${ticketInfo.endTimeStr }">
					<div class="weui-form-li tick-form-li" id="timerDate">
						<input class="weui-form-checkbox" name="f1" id="${ticketInfo.id}"
							value="${ticketInfo.minimumNumber}" type="radio"> <label
							for="${ticketInfo.id}">
							<div class="weui-form-text">
								<p>
									${ticketInfo.name}&nbsp;&nbsp;&nbsp;&nbsp;￥<span
										class="ticket_price">${ticketInfo.price/100}</span> <span>(必须满足${ticketInfo.minimumNumber}人条件)</span>
								</p>
							</div> <i class="weui-icon-radio"></i>
						</label>
					</div>
				</div>
			</c:forEach>


			<div class="weui-cell">
				<div class="weui-cell__hd">
					<p class="">选择日期</p>
				</div>
				<div class="weui-cell__bd">
					<span
						style="float: right; font-size: 14px; margin-right: 2%; color: #f39800"
						id="spanDateSelected">点击选择日期</span>
				</div>
			</div>

			<div class="weui-cell" style="height: 50px;">
				<div class="weui-cell__hd">
					<p>门票数量</p>
				</div>
				<div class="weui-cell__bd">
					<span class="ui-tic-title"
						style="margin-right:2%; font-size: 14x; padding-top: 2px; float: right;">
						<span class="reduce">-</span> <span class="ticketNum" id="ticketNum"
						style="width: 46px;">1</span> <span class="plus">+</span>
					</span>
				</div>

			</div>

		</div>
		<p style="padding-left: 25px;">
			取票人信息 <span class="ui-panel-title-tips"
				style="margin-right: 20px; font-size: 16px;"
				id="userReceiveInfoMaps">选择联系人</span>
		</p>
		<div class="ticketCollector">
			<div class="weui-cell">
				<div class="weui-cell__hd">
					<label class="weui-label" >姓名</label>
				</div>
				<div class="weui-cell__bd">
					<input class="weui-input" placeholder="请输入姓名（必填）"  id="userReceiveName" type="text" maxlength="10">
				</div>

			</div>
			<div class="weui-cell">
				<div class="weui-cell__hd">
					<label class="weui-label">手机号</label>
				</div>
				<div class="weui-cell__bd">
					<input class="weui-input" placeholder="请输入手机号（必填）" id="userReceivePhone" maxlength="11"
						pattern="[0-9]{11}" type="tel">
				</div>

			</div>
			<div class="weui-cell">
				<div class="weui-cell__hd">
					<label class="weui-label">身份证</label>
				</div>
				<div class="weui-cell__bd">
					<input class="weui-input" placeholder="请输入身份证（选填）" id="userReceiveNumber" maxlength="18"
						pattern="[0-9]{17}[xX0-9]" type="tel">
				</div>

			</div>
			<div class="weui-cell">
				<div class="weui-cell__hd">
					<label class="weui-label">是否驾车</label>
				</div>
				<div class="weui-cell__bd">
					<div class="weui-cell__ft"
						style="padding-top: 3px; float: right; padding-right: 8%">
						<label for="switchCP" class="weui-switch-cp"> <input
							id="switchCP" class="weui-switch-cp__input" type="checkbox">
							<div class="weui-switch-cp__box"></div>
						</label>
					</div>
				</div>
			</div>

			<div class="carNo weui-cell" style="height: 55px;">
				<div class="weui-cell__hd" style="width: 24%;">
					<label class="weui-label">添加车牌</label>
				</div>

				<div style="width: 76%;" class="car_input weui-cell__bd" data-pai="${scenicSpotDetailVo.carNoPrefix }">
					<ul class="clearfix ul_input car_no" id="carNoUl">
						<li class='input_pro carNomber  ${scenicSpotDetailVo.carNoPrefix != null ? "hasPro": ""}'><span
							class='${scenicSpotDetailVo.carNoPrefix != null ? "have-text": ""}'>${scenicSpotDetailVo.carNoPrefix != null ? scenicSpotDetailVo.carNoPrefix.substring(0,1) : ""}</span></li>
						<li class='input_pp input_zim carNomber ${scenicSpotDetailVo.carNoPrefix != null ? "ppHas": ""}'><span
							class='${scenicSpotDetailVo.carNoPrefix != null ? "have-text": ""}'>${scenicSpotDetailVo.carNoPrefix != null ? scenicSpotDetailVo.carNoPrefix.substring(1) : ""}</span></li>
						<li style="width: 5%">·</li>
						<li class="input_pp carNomber"><span></span></li>
						<li class="input_pp carNomber"><span></span></li>
						<li class="input_pp carNomber"><span></span></li>
						<li class="input_pp carNomber"><span></span></li>
						<li class="input_pp carNomber"><span></span></li>
						<li class="input_pps carNomber"><span class="have-text">+</span></li>
					</ul>
				</div>


			</div>
		</div>
		<div class="carNobmer" id="carNobmer"></div>

		<div class="touristInformation">
			<p style="padding: 10px 0 0 25px;">
				游客信息 <span class="ui-panel-title-tips"
					style="margin-right: 20px; font-size: 16px;" id="userIdInfoMaps">选择联系人</span>
			</p>
			<div class="tourist">
				<div class="weui-cell">
					<div class="weui-cell__hd">
						<label class="weui-label">姓名</label>
					</div>
					<div class="weui-cell__bd">
						<input class="weui-input InfouserName InfouserNames" placeholder="请输入姓名（必填）" type="text" maxlength="10">
					</div>

				</div>
				<div class="weui-cell">
					<div class="weui-cell__hd">
						<label class="weui-label">手机号</label>
					</div>
					<div class="weui-cell__bd">
						<input class="weui-input Infophone Infophones" placeholder="请输入手机号（必填）" type="number" maxlength="11">
					</div>

				</div>
				<div class="weui-cell">
					<div class="weui-cell__hd">
						<label class="weui-label">身份证</label>
					</div>
					<div class="weui-cell__bd">
						<input class="weui-input InfoidNumber InfoidNumbers" placeholder="请输入身份证（必填）" type="tel" maxlength="18">
					</div>

				</div>
			</div>


		</div>
		<div class="scenicDesc">
			<p  id="scenicDesc">购票须知<img src="${ctx}/static/images/dropDown.png"></p>
			<p  class="desc">资费说明：</p>
			<p id="priceDesc">${scenicSpotDetailVo.priceDesc }</p>
			<p  class="desc">使用说明：</p>
			<p id="useDesc">${scenicSpotDetailVo.useDesc }</p>
			<p  class="desc">退票规则：</p>
			<p class="returnTicketRule">${scenicSpotDetailVo.returnTicketRule }</p>
		</div>
		
	</div>
	<div style="height: 70px; width: 100%;"></div>
	<div class="priceDisplay">
		<div>
			<p class="prices">
				总额：￥<span class="price"></span>
			</p>
		</div>
		<div>
			<span href="" class="weui-btn bg-orange" id="immediately_order">立即下单</span>
		</div>
	</div>


</body>


<script src="${ctx}/static/js/jquery/jquery-3.2.1.min.js"></script>
<script src="${ctx}/static/js/laydate/laydate.js"></script>
<script src="${ctx}/static/plug/frozenui-1.3.0/js/frozen.js"></script>

<script src="${ctx}/static/js/user/addCarNo.js"></script>
<script src="${ctx}/static/plug/layer_mobile/layer.js"></script>
<script src="${ctx}/static/js/common.js"></script>
<script src="${ctx}/static/js/aes.js"></script>
<script src="${ctx}/static/plug/weui/js/zepto.weui.js"
	type="text/javascript"></script>
<script src="${ctx}/static/plug/weui/js/zepto.min.js"
	type="text/javascript"></script>


<script>
	$(function() {
		$("#scenicDesc").click(function() {
			console.log($(".desc").css("display"));
			if($(".desc").css("display") == "none"){
				$("#scenicDesc img").attr("src" , "${ctx}/static/images/retract.png");
				$(" .scenicDesc >p").css("display","block");
			}else {
				$("#scenicDesc img").attr("src" , "${ctx}/static/images/dropDown.png");
				$(" .scenicDesc >p").css("display","none");
				$("#scenicDesc").css("display","block");
			}
		});
		
		var paramObj = {
				"payAppId" : "${scenicSpotDetailVo.payAppId}",
				"appId" : "${scenicSpotDetailVo.appId}",
				"payAccountId" :"${scenicSpotDetailVo.payAccountId}"
			};
		
		$(".plus").click(function() {
			var num = $("#ticketNum").html();
			num = parseInt(num);
			$("#ticketNum").text(num + 1);
			$(".tickets").text(num + 1);
			htmlUtil(1);
			$(".price").text((num + 1) * prices);
		});
		
		$(".reduce").click(function() {
			var num = $("#ticketNum").html();
			num = parseInt(num);
			if (num > mintickets) {
				$("#ticketNum").text(num - 1);
				$(".tickets").text(num - 1);
				$(".price").text((num - 1) * prices);
				htmlUtil(-1);
			}
		});
		
		$("#userReceiveName").blur(function(){
			if($(".tourist").first().find(".InfouserName").val() == ""){
				$(".tourist").first().find(".InfouserName").val($("#userReceiveName").val());
				}
			});

		$("#userReceivePhone").blur(function(){
			if($(".tourist").first().find(".Infophone").val() == ""){
				$(".tourist").first().find(".Infophone").val($("#userReceivePhone").val());
				}
			});

		$("#userReceiveNumber").blur(function(){
			if($(".tourist").first().find(".InfoidNumber").val() == ""){
				$(".tourist").first().find(".InfoidNumber").val($("#userReceiveNumber").val());
				}
			});
		
		
		
		$("#immediately_order").click(function () {
			var reg=/^[1-9][0-9]{5}(19|20)[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|30|31)|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}([0-9]|x|X)$/;

			var payOpenid = $("#payOpenid").val();
			var userId = $("#userId").val();
			var ticketInfoId = $("input[type='radio'][name='f1']:checked").attr("id");
			if(!ticketInfoId){
				 $.toast("请选择票类型", "forbidden");
				return;
			}
			var ticketInfoNum = $("#ticketNum").text();
			var entryTime = $("#spanDateSelected").text();
			if(entryTime == "点击选择日期") {
				 $.toast("请选择日期", "forbidden");
				return;
			}
			var userReceiveInfoVal = new Object();
			userReceiveInfoVal.name = $("#userReceiveName").val();
			console.log(userReceiveInfoVal.name.length + "     " +userReceiveInfoVal.name);
			console.log(2 >userReceiveInfoVal.name.length ||5 <userReceiveInfoVal.name.length);
			if(2 >userReceiveInfoVal.name.length ||5 <userReceiveInfoVal.name.length){
				 $.toast("取票人姓名不正确", "forbidden");
				 return;
			}
			userReceiveInfoVal.phone = $("#userReceivePhone").val();
			if(userReceiveInfoVal.phone.length != 11){
				 $.toast("取票人手机号码位数不正确", "forbidden");
				return;
			}
			userReceiveInfoVal.idNumber = $("#userReceiveNumber").val();
			console.log(userReceiveInfoVal.idNumber);
			if(userReceiveInfoVal.idNumber == "" || !reg.test(userReceiveInfoVal.idNumber)){
				 $.toast("取票人身份证输入不正确", "forbidden");
				return;
			}
			if($("#switchCP").prop("checked")){
				var carNo = $(".car_input").attr("data-pai");
				if(!(6< carNo.length <9) ){
					$.toast("取票人车牌位数输入不正确", "forbidden");
					return;
				}
				carNo=carNo.replace(/\+/g, "");
				userReceiveInfoVal.carNo = carNo;
			}
			
			var userIdInfoList = new Array();
			for (var i = 0; i < $(".tourist").length; i++) {
				var userIdInfoId = new Object();
				userIdInfoId.userName = $(".tourist").eq(i).find(".InfouserName").val();
				if(2 >userReceiveInfoVal.name.length ||5 <userReceiveInfoVal.name.length){
					 $.toast("游客姓名不正确", "forbidden");
					 return;
				}
				userIdInfoId.phone = $(".tourist").eq(i).find(".Infophone").val();
				if(userIdInfoId.phone.length != 11){
					 $.toast("游客手机号码位数不正确", "forbidden");
					return;
				}
				userIdInfoId.idNumber = $(".tourist").eq(i).find(".InfoidNumber").val();
				if(userIdInfoId.idNumber == "" || !reg.test(userIdInfoId.idNumber)){
					 $.toast("游客身份证输入不正确", "forbidden");
					return;
				}
				userIdInfoList[i] = userIdInfoId;
			}
			var param={
					"userReceiveInfoVal": userReceiveInfoVal,
					"userIdInfoList": userIdInfoList,
					"userId":  userId ,
					"ticketInfoId":ticketInfoId,
					"ticketInfoNum":ticketInfoNum,
					"entryTime":entryTime,
					"payAccountId":paramObj.payAccountId,
					"appId":paramObj.appId,
			}
			
			param = aesHex(JSON.stringify(param));
			if(payOpenid){
				
				window.location.href='${ctx}/scenicSpot/ticket/orderIndex?'+ "appId="+ paramObj.payAppId+ "&openId=" + payOpenid + "&touristJson=" +param;
			}else{
				var url = 'http://test.ticketing.boshukeji.com/scenicSpot/ticket/orderIndex?' + "touristJson=" +encodeURI(param);
				var redirectUri = "http://test.wx.boshukeji.com/redirectManagerOnlyOpenid?url=" + url;
				window.location.href="https://open.weixin.qq.com/connect/oauth2/authorize?appid="+ paramObj.payAppId + "&redirect_uri="
				+ encodeURI(redirectUri) + "&response_type=code&scope=snsapi_base&state=" + paramObj.payAppId
				+ "#wechat_redirect"
			}
		});
		
		
		
		
		
		var userIdInfoMap = {};
		var userReceiveInfoMap = {};
		var userIdInfovalues = new Array();
		var userReceiveInfovalues = new Array();
		var valueArr = new Array();
		userId = $("#userId").val();
		var param = {
			"userId" : userId
		}
		console.log(param);
			$.post(
						"${ctx}/scenicSpot/user/findInformation",
						param,
						function(obj) {
							var userIdInfoList = obj.userIdInfoList;
							var userReceiveInfoList = obj.userReceiveInfoList;

							for (var i = 0; i < userIdInfoList.length; i++) {
								var userIdInfo={
										"title" : userIdInfoList[i].userName ,
										"value" : userIdInfoList[i]
								}
								userIdInfoMap[userIdInfoList[i].userName] = userIdInfoList[i];
								userIdInfovalues[i] = userIdInfo;
							}
							for (var i = 0; i < userReceiveInfoList.length; i++) {
								var userReceiveInfo={
										"title" : userReceiveInfoList[i].name ,
										"value" : userReceiveInfoList[i]
								}
								userReceiveInfoMap[userReceiveInfoList[i].name] = userReceiveInfoList[i];
								userReceiveInfovalues[i] = userReceiveInfo;
							}
							
							if(userReceiveInfovalues.length != 0){
								$("#userReceiveInfoMaps").select({
							        title: "选择您常用的取票人信息",
							        items: userReceiveInfovalues,
							        onChange: function(d) {
							        	console.log(this.data);
							        	if(this.data.titles){
							        		var values = userReceiveInfoMap[this.data.titles];
							        		$("#userReceiveName").val(values.name);
							        		$("#userReceivePhone").val(values.phone);
							        		$("#userReceiveNumber").val(values.idNumber);
							        		
							        		if($(".tourist").first().find(".InfouserName").val() == ""){
							        			$(".tourist").first().find(".InfouserName").val(values.name);
							        		}
							        		if($(".tourist").first().find(".Infophone").val() == ""){
							        			$(".tourist").first().find(".Infophone").val(values.phone);
							        		}
							        		if($(".tourist").first().find(".InfoidNumber").val() == ""){
							        			$(".tourist").first().find(".InfoidNumber").val(values.idNumber);
							        		}
							        		
							        		if(values.carNo){
							        			if($("#switchCP").prop("checked")){
							        				
							        			}else{
							        				$("#switchCP").click();
							        			}
							        			$(".car_input").attr("data-pai",values.carNo);
							        			for (var i = 0; i < values.carNo.length; i++) {
													$("#carNoUl").find(".carNomber").eq(i).children().text(values.carNo.charAt(i))
													$("#carNoUl").find(".carNomber").eq(i).children().addClass("have-text");
												}
							        		}else {
												if($("#switchCP").prop("checked")){
													$("#switchCP").click();
							        			}
											}
							        	}
							           
							        },
							        onClose: function() {
							            console.log("close");
							        },
							        onOpen: function() {
							            console.log("open");
							        },
							    });
							}else {
								$("#userReceiveInfoMaps").click(function() {
									$.toast("没有联系人信息", "forbidden");
								});
							}
							
							if(userIdInfovalues.length != 0){
								$("#userIdInfoMaps").select({
							        title: "选择您常用的游客信息",
							        multi:true,
							        items: userIdInfovalues,
							        onChange: function(d) {
							        	$(".tourist").find(".InfouserName").not(".InfouserNames").val("");
							        	$(".tourist").find(".Infophone").not(".Infophones").val("");
							        	$(".tourist").find(".InfoidNumber").not(".InfoidNumbers").val("");
							        	if(this.data.titles){
						        			var titleArr=this.data.titles.split(",")
						        			titleArr.forEach(function (item,index,array){
						        				console.log(array[index]);
						        				if(array[index] == $("#userReceiveName").val()){
						        					console.log(index);
						        					array.splice(index,1);
						        				}
						        			});
						        			console.log(titleArr);
						        			if(titleArr.length > $(".tourist").length){
						        				$(".close-select").click(function() {
						        					$.toast("一张票只能添加一名游客", "forbidden");			
						        				});
						        			}
						        			if($(".tourist").first().find(".InfouserName").val() == "" && 
						        					$(".tourist").first().find(".Infophone").val() == "" && 
						        					$(".tourist").first().find(".InfoidNumber").val() == ""){
						        				var numVal = 0;
						        			}else {
						        				var numVal = 1;
											}
						        			console.log(numVal);
						        			for (var i = numVal; i <= titleArr.length; i++) {
						        				if(numVal == 0){
						        					var values = userIdInfoMap[titleArr[i]];
						        				}else {
						        					var values = userIdInfoMap[titleArr[i-1]];
												}
						        				console.log(values);
						        				$(".tourist").eq(i).find(".InfouserName").val(values.userName);
								        		$(".tourist").eq(i).find(".Infophone").val(values.phone);
								        		$(".tourist").eq(i).find(".InfoidNumber").val(values.idNumber);
						        				
											}
						        			var values = userIdInfoMap[this.data.titles];
						        		}
							        },
							        onClose: function() {
							            console.log("close"+this.data);
							        },
							        onOpen: function() {
							            console.log("open");
							        },
							    });
							}else {
								$("#userIdInfoMaps").click(function() {
									$.toast("没有联系人信息", "forbidden");
								});
							}
						});
		


		if ($("#switchCP").prop("checked")) {
			$(".carNo").css("display", "block");
		} else {
			$(".carNo").css("display", "none");
		}

		var date = new Date();
		var currentDate = date.getFullYear() + '-' + (date.getMonth() + 1)
				+ '-' + date.getDate();
		
		var minTime = currentDate;
		var maxTime;
		
		$("#timerDate>label").click(function() {
			minTime = $(this).parent().parent().attr("minTime");
			maxTime = $(this).parent().parent().attr("maxTime");
			console.log(minTime)
			console.log(maxTime)
			setTimeout(ticketPrice, 500);
			dateTimes();
		});
		$("#timerDate>label").first().click();	
		var mintickets = $("input[type='radio'][name='f1']:checked").val();
		mintickets = parseInt(mintickets);
		var prices = $("input[type='radio'][name='f1']:checked").parents(
				".weui-form-li").find(".ticket_price").text();
		if (prices) {
			prices = parseInt(prices);
			console.log(prices);
		} else {
			prices = 0;
			console.log(prices);
		}
		ticketPrice();

		function ticketPrice() {
			var num = $("input[type='radio'][name='f1']:checked").val();
			var ticketPrices = $("input[type='radio'][name='f1']:checked")
					.parents(".weui-form-li").find(".ticket_price").text();
			console.log(ticketPrices)
			ticketPrices = parseFloat(ticketPrices);
			if (ticketPrices) {
				prices = ticketPrices;
				console.log(prices);
			}
			$(".ticprice").text(ticketPrices);

			console.log(num);
			num = parseInt(num);
			var ticketNum = $("#ticketNum").text();
			ticketNum = parseInt(ticketNum);
			htmlUtil(num - ticketNum);
			mintickets = num;
			$(".tickets").text(num);
			if (num && ticketPrices) {
				$("#ticketNum").text(num);
				$(".price").text(num * ticketPrices);
				return;
			}
			$(".ticketNum").text(1);
			$(".price").text(0);
			$(".ticprice").text(0);
			$(".tickets").text(1);
		}

		$("#switchCP").click(function() {
			if ($("#switchCP").prop("checked")) {
				$(".carNo").css("display", "block");

			} else {
				$(".carNo").css("display", "none");
				$("#carNobmer").html("");
			}
		});


		function htmlUtil(val) {
			var html = '<div class="tourist"><div class="weui-cell"><div class="weui-cell__hd"><label class="weui-label">姓名</label></div>'
					+ '<div class="weui-cell__bd"><input class="weui-input InfouserName" placeholder="请输入姓名（必填）" type="text" maxlength="10"></div></div>'
					+ '<div class="weui-cell"><div class="weui-cell__hd"><label class="weui-label">手机号</label></div>'
					+ '<div class="weui-cell__bd"><input class="weui-input Infophone" placeholder="请输入手机号（必填）" pattern="[0-9]{11}"  type="number" maxlength="11"></div></div>'
					+ '<div class="weui-cell"><div class="weui-cell__hd"><label class="weui-label">身份证</label></div>'
					+ '<div class="weui-cell__bd"><input class="weui-input InfoidNumber" placeholder="请输入身份证（必填）" type="tel" maxlength="18"></div></div></div>';
			if (val < 0) {
				for (var i = val; i < 0; i++) {
					$(".tourist").last().remove();
				}
			}
			var htmlVal = "";
			for (var i = 0; i < val; i++) {
				htmlVal += html;
			}
			$(".touristInformation").append(htmlVal);
		}

		var carNo;
		$("#btnCancel").click(function() {
			$(".ui-dialog").removeClass("show");
		});

		$("#newCarCheckBox").click(function() {
			if (this.checked) {
				$("#carNoUl").append(genCarNoInput());
				$("#carNoUl").removeClass("car_no");
				$("#carNoUl").addClass("new_car_no");
			} else {
				$("#carNoUl").addClass("car_no");
				$("#carNoUl").removeClass("new_car_no");
				$("#carNoUl li:last").remove();
			}
		});

		$("#btnAddCarNo").click(function() {
			carNo = $(".car_input").attr("data-pai");
			var ifNewCarNo = $("#newCarCheckBox")[0].checked;
			if (!carNo || carNo.length < 7) {
				showTips("warn", "车牌号位数不对！");
				return;
			}

			if (carNo.length < 8 && ifNewCarNo) {
				showTips("warn", "新能源车牌为8位！");
				return;
			}

			if (!ifNewCarNo) {
				carNo = carNo.substr(0, 7);
			}
			$(".ui-dialog").addClass("show");
			$(".ui-dialog-bd p").html("车牌是否为：" + carNo);
		});
		function dateTimes() {
			console.log(minTime)	
			console.log(maxTime)	
			$("#spanDateSelected").html(minTime);

			laydate.render({
				elem : '#spanDateSelected' //指定元素
				,
				min : minTime,
				max: maxTime,
				change : function(value, date, endDate) {
				},
				showBottom : false
				,trigger: 'click'
			});
			setTimeout(function() {
				$("#spanDateSelected").click();
			}, 500);
		}

	});

</script>
</html>



